import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from "../views/Home.vue"
import Cart from "../views/Cart.vue"
import Kinds from "../views/Kinds.vue"
import Mine from "../views/Mine.vue"
import Error from "../views/Error.vue"
import Detail from "../views/Detail.vue"
import MyFooter from "../components/Footer/MyFooter"

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'Home',
    components: {
      default: Home,
      MyFooter: MyFooter//键名和键值一样的情况下可以只写一个
    }
  },
  {
    path: '/kinds',
    name: 'Kinds',
    components: {
      default: Kinds,//显示两个组件
      MyFooter: MyFooter//显示两个组件
    }
  },
  {
    path: '/cart',
    name: 'Cart',
    components: {
      default: Cart,
      MyFooter: MyFooter
    }
  },
  {
    path: '/mine',
    name: 'Mine',
    components: {
      default: Mine,
      MyFooter: MyFooter
    }
  },
  {
    path: '/detail/:proid',
    name: 'Detail',
    component: Detail
  },
  {
    path: '*',//不是路由规则中的路由时，出现这个页面
    name: "Error",
    component: Error
  }
]

const router = new VueRouter({
  routes
})

export default router
